import datetime

def days_until_end_of_month(year, month, day):
    # 创建给定日期的日期对象
    given_date = datetime.date(year, month, day)
    
    # 获取下个月的第一天
    if month == 12:
        next_month = datetime.date(year + 1, 1, 1)
    else:
        next_month = datetime.date(year, month + 1, 1)
    
    # 计算月底日期
    end_of_month = next_month - datetime.timedelta(days=1)
    
    # 计算距离月底的天数
    days_left = (end_of_month - given_date).days
    
    return days_left

# 示例使用
year = int(input())
month = int(input())
day = int(input())

days_left = days_until_end_of_month(year, month, day)
print(days_left)